import Book from "../../models/book";
import Person from "../../models/person";

export default {
    Query: {
        allPeople: async () => {
            return Person.findAll({ include: [{ model: Book, as: "books" }] });
        },
        person: async (context: any, { id }: { id: number }) => {
            return Person.findByPk(id);
        },
    },
    Mutation: {
        addPeople: async (context: any, { name, gender, homeWorld }:
            { gender: string, homeWorld: string, name: string }) => {
            return await Person.create({
                name, gender, homeWorld
            });
        },
    }
};
